<?php

namespace app\admin\model;

use think\Model;


class Command extends Model
{


    // 表名
    protected $name = 'command';
    //    public $table = 'nsig_project';
    // 自动写入时间戳字段
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';

    // 定义时间戳字段名
    protected $createTime = 'create_time';
    protected $updateTime = 'update_time';
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'access_time_text',
        'sign_time_text',
        'framework_agreement_time_text',
        'invesment_agreement_time_text',
        'register_time_text',
        'land_time_text',
        'start_construction_time_text',
        'create_time_text',
        'update_time_text',
    ];

    public function getCreateTimeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['create_time']) ? $data['create_time'] : '');
        return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
    }
    public function getUpdateTimeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['update_time']) ? $data['update_time'] : '');
        return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
    }
    public function getFrameworkAgreementTimeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['framework_agreement_time']) ? $data['framework_agreement_time'] : '');
        return is_numeric($value) ? date("Y-m-d", $value) : $value;
    }
    public function getInvesmentAgreementTimeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['invesment_agreement_time']) ? $data['invesment_agreement_time'] : '');
        return is_numeric($value) ? date("Y-m-d", $value) : $value;
    }

    public function getAccessTimeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['access_time']) ? $data['access_time'] : '');
        return is_numeric($value) ? date("Y-m-d", $value) : $value;
    }

    public function getSignTimeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['sign_time']) ? $data['sign_time'] : '');
        return is_numeric($value) ? date("Y-m-d", $value) : $value;
    }
    public function getRegisterTimeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['register_time']) ? $data['register_time'] : '');
        return is_numeric($value) ? date("Y-m-d", $value) : $value;
    }
    public function getStartConstructionTimeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['start_construction_time_text']) ? $data['start_construction_time_text'] : '');
        return is_numeric($value) ? date("Y-m-d", $value) : $value;
    }
    public function getLandTimeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['land_time']) ? $data['land_time'] : '');
        return is_numeric($value) ? date("Y-m-d", $value) : $value;
    }

    protected function setCreateTimeAttr($value)
    {
        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
    }
    protected function setUpdateTimeAttr($value)
    {
        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
    }
    protected function setInvesmentAgreementTimeAttr($value)
    {
        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
    }
    protected function setFrameworkAgreementTimeAttr($value)
    {
        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
    }
    protected function setAccessTimeTextAttr($value)
    {
        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
    }
    protected function setSignTimeTextAttr($value)
    {
        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
    }
    protected function setRegisterTimeTextAttr($value)
    {
        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
    }
    protected function setStartConstructionTimeTextAttr($value)
    {
        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
    }
    protected function setLandTimeTextAttr($value)
    {
        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
    }
}
